const http = require('http');

// 创建http应用服务实例对象
let sever = http.createServer();

// 给实例绑定要接受的request
sever.on("request", (req, res) => {
  console.log(`请求的URL是: ${req.url}`);
  console.log(req.headers);
  res.setHeader("Content-type", "text/plain;charset=utf-8");
  console.log(1111,req.url);
  res.write('This is my first NodeJs API');
  res.write('777');
  res.write('您好');
  res.end();
})

// 绑定监听端口，开启服务
sever.listen(8080, '127.0.0.1', () => {
  console.log(`服务器开始监听！端口是: ${8080}`);
})
